﻿using pingjia.bll;
using PJTY.dal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class views_admin_Default : System.Web.UI.Page
{
    private ConsumerService consumerService = new ConsumerService();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Button2_Click(sender, e);
        }
    }

    protected void Unnamed2_Click(object sender, EventArgs e)
    {
        // 当前未实现逻辑
    }

    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        // 当前未实现逻辑
    }

    protected void rptProducts_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        // 处理 Repeater 控件的命令事件
    }

    protected void lnkSelect_Click(object sender, EventArgs e)
    {
        // 处理链接点击事件
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string keyword = TextBox1.Text.Trim();
        LoadProductsByKeyword(keyword);
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        LoadAllProducts();
    }

    private void LoadAllProducts()
    {
        var products = consumerService.GetAllProducts();
        BindProductsToRepeater(products);
    }

    private void LoadProductsByKeyword(string keyword)
    {
        var products = consumerService.GetProductsByKeyword(keyword);
        BindProductsToRepeater(products);
    }

    private void BindProductsToRepeater(List<Product1> products)
    {
        rptProducts.DataSource = products;
        rptProducts.DataBind();
    }
}